#include <string.h>
#include <iostream>
using std::cout;
using std::endl;

class Student{
public:
    //构造函数中使用了new，析构函数必然需要delete
    Student(const char * name,int num,int age)
    : _name(new char[strlen(name) + 1]())
    , _num(num)
    , _age(age)
    {
        strcpy(_name,name);
        cout << "Student(const char * ,int, int)" << endl;
    }

    ~Student(){
        if(_name){
            delete [] _name;
            _name = nullptr;
        }
        cout << "~Student()" << endl;
    }
private:
    char * _name;
    int _num;
    int _age;
};


void test0(){
    Student stu1("Jack",100,18);
}

int main(void){
    test0();
    return 0;
}
